package org.example.everyday;

/**
 * <p>
 * Description:TODO 详细描述
 * <p>
 * <p>
 *
 * @author anlu
 * @date 2022/5/18 0018 9:40
 */
public class Lc668 {
    public static void main(String[] args) {
        Lc668 lc668 = new Lc668();
        int m = 3, n = 3, k = 5;
        int res = lc668.findKthNumber(m,n,k);
        System.out.println(res);
    }

    public int findKthNumber(int m, int n, int k) {
        int left = 1, right = m * n;
        while (left < right){
            int x = left + (right - left) / 2;
            int count = x / n * n;
            for (int i = x/n + 1; i <= m; i++) {
                count += x / i;
            }
            if(count >= k){
                right = x;
            }else{
                left = x + 1;
            }
        }
        return left;
    }
}
